package com.ziyia.popupwindow;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.Toast;

import static com.ziyia.popupwindow.R.color.black;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void loadClick(View view) {
        View inflate = getLayoutInflater().inflate(R.layout.acitvity_test, null);

        Button b6 = inflate.findViewById(R.id.b6);

        PopupWindow popupWindow = new PopupWindow(inflate, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, true);



        View inflate1 = getLayoutInflater().inflate(R.layout.activity_main, null);

//        popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.hh));
//        popupWindow.showAsDropDown(view);


        popupWindow.setBackgroundDrawable(getDrawable(R.drawable.hh));
        popupWindow.showAtLocation(inflate1, Gravity.BOTTOM, 0,100);


        b6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "关闭操作",Toast.LENGTH_SHORT).show();
                popupWindow.dismiss();
            }
        });

    }
}